﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.ComponentModel.DataAnnotations;

namespace DDD.Domain
{
    internal class EntityGetPropertiesExt<T>
    {
        internal static PropertyInfo[] properties { get; set; }

        static EntityGetPropertiesExt()
        {
            if (properties == null)
            {
                //TODO: BindingFlags.DeclaredOnly为啥不起作用了？？？
                //properties = typeof(T).GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Instance);
                properties = typeof(T).GetProperties().Where(e => e.DeclaringType == typeof(T) || e.GetCustomAttributes(typeof(TimestampAttribute)).Any()).ToArray();
            }
        }
    }
}
